class EventBus {
	constructor() {
		this.callbacks = {
			// a:[fn,fn,...]
		}
	}
	on(type, callback) {
		if (this.callbacks[type]) {
			this.callbacks[type].push(callback);
		} else {
			this.callbacks[type] = [callback];
		}
	}
	emit(type, args) {
		if (!this.callbacks[type]) return;
		if (!this.callbacks[type].length === 0) return;
		this.callbacks[type].forEach((callback) => {
			callback(args);
		})
	}
	off(type) {
		if (type) {
			delete this.callbacks[type];
		} else {
			this.callbacks = {};
		}
	}
}
export let bus = new EventBus();